SELECT MAX(lead_col1) FROM (SELECT col1, LEAD(col1) OVER(PARTITION BY col7 ORDER BY col1) lead_col1 , col7 FROM "allTypsUniq.parquet") sub_query WHERE col7 NOT IN (false)